package com.swak.proxy.mock;

import com.swak.proxy.HelloService;
import com.swak.proxy.HelloServiceImpl;

@SuppressWarnings("unused")
public class MockCglibHelloService implements HelloService {

	Object[] attrs = new Object[0];

	private static class FastClassInfo {
		FastClass f1;
		FastClass f2;
		int i1;
		int i2;
	}

	private static class MethodInvoker {

	}

	private static class MethodProxy {

	}

	private static class FastClass {

	}

	private final Object initLock = new Object();
	private volatile FastClassInfo fastClassInfo;
	private HelloService service;
	private MethodInvoker methodInvoker = new MethodInvoker();
	private MethodProxy methodProxy;

	public MockCglibHelloService(HelloService service) {
		this.service = service;
	}

	private void init() {
		if (fastClassInfo == null) {
			synchronized (initLock) {
				if (fastClassInfo == null) {
					FastClassInfo fci = new FastClassInfo();
					fastClassInfo = fci;
				}
			}
		}
	}

	@Override
	public void say() {
		this.mockInvokerHandle(0, service, attrs);
	}

	private Object mockInvokerHandle(int i, Object obj, Object[] objArr) {
		return this.mockMethodProxy(i, obj, objArr);
	}

	private Object mockMethodProxy(int i, Object obj, Object[] objArr) {
		try {
			init();
			FastClassInfo fci = fastClassInfo;
			return this.mockFastClassInvoke(0, service, attrs);
		} catch (IllegalArgumentException e) {
			throw e;
		}
	}

	@SuppressWarnings("removal")
	private Object mockFastClassInvoke(int i, Object obj, Object[] objArr) {
		HelloServiceImpl helloServiceImpl = (HelloServiceImpl) obj;
		try {
			switch (i) {
			case 0:
				helloServiceImpl.say();
				return null;
			case 1:
				return new Boolean(helloServiceImpl.equals(objArr[0]));
			case 2:
				return helloServiceImpl.toString();
			case 3:
				return new Integer(helloServiceImpl.hashCode());
			default:
				throw new IllegalArgumentException("Cannot find matching method/constructor");
			}
		} catch (Throwable unused) {
			return null;
		}
	}
}
